package edu.tongji.gridding.thread;

import java.util.List;
import java.util.concurrent.CountDownLatch;

import edu.tongji.gridding.database.TitleIndexDao;
import edu.tongji.gridding.datamodel.Result;


public class TitleQueryThread extends Thread{
	private TitleIndexDao dao;
	private String keyword;
	private int cnt;
	private CountDownLatch CDL;
	private List<Result> results;
	
	public TitleQueryThread(TitleIndexDao dao, String keyword, int cnt,
			CountDownLatch CDL, List<Result> results) {
		this.dao = dao;
		this.keyword = keyword;
		this.cnt = cnt;
		this.CDL = CDL;
		this.results = results;
	}
	
	@Override
	public void run() {
		Result result = new Result();
		List<String> l = dao.queryTitle(keyword, cnt);
		result.setKeyword(keyword);
		result.setReulsts(l);
		result.setCnt(l.size());
		results.add(result);
		CDL.countDown();
	}
	
	
	
	
	

}
